﻿@using Luckyu.App.Organization;
@using Luckyu.App.Workflow;
@{
    Layout = "~/Views/Shared/_LayoutMobile.cshtml";

    var loginInfo = ViewBag.UserInfo as UserModel;
    var instance = ViewBag.Instance as wf_flow_instanceEntity;
    var forms = ViewBag.Forms as List<WFFormModel>;
    var formType = ViewBag.FormType.ToString();
}

<div class="bui-page bui-box-vertical">
    <header>
        <div class="bui-bar">
            <div class="bui-bar-left">
                <div class="bui-btn" onclick="bui.back();"><i class="icon-back"></i></div>
            </div>
            <div class="bui-bar-main">
                @instance.processname
            </div>
            <div class="bui-bar-right">
            </div>
        </div>
    </header>
    <main>
        <div id="tabFoot" class="bui-tab bui-box-vertical">
            <div class="bui-tab-main">
                <ul>
                    <li>
                        @if (!forms.IsEmpty())
                        {
                            <div id="tabForm" class="bui-tab bui-box-vertical">
                                <div class="bui-tab-head">
                                    <ul class="bui-nav">
                                        @for (int i = 0; i < forms.Count; i++)
                                        {
                                            <li class="bui-btn">@forms[i].formname</li>
                                        }
                                    </ul>
                                </div>
                                <div class="bui-tab-main">
                                    <ul id="ulForm">
                                        @for (int i = 0; i < forms.Count; i++)
                                        {
                                            <li style="@(i==0?"display: none;":"")">
                                                <iframe src="@($"{forms[i].mobileformurl}?keyValue={instance.process_id}")" frameborder="0" border="0"></iframe>
                                            </li>
                                        }
                                    </ul>
                                </div>
                            </div>
                        }
                    </li>
                    <li style="display: none;">
                        @if (formType == "task" || formType == "read")
                        {
                            <div class="bui-fluid" id="appform">
                                @if (formType == "task")
                                {
                                    <div class="span12">
                                        <div class="section-title">审批结果</div>
                                        <ul class="bui-list">
                                            <li class="bui-btn bui-box">
                                                <div class="span1">
                                                    <label for="result1">通过</label>
                                                </div>
                                                <input id="result1" type="radio" class="bui-choose" name="result" value="1" checked="checked" />
                                            </li>
                                            <li class="bui-btn bui-box bui-btn-line">
                                                <div class="span1">
                                                    <label for="result2">退回</label>
                                                </div>
                                                <input id="result2" type="radio" class="bui-choose" name="result" value="2" />
                                            </li>
                                        </ul>
                                    </div>
                                    <div class="span12" id="divReturn" style="display:none;">
                                        <div class="section-title">退回规则</div>
                                        <ul class="bui-list">
                                            <li class="bui-btn bui-box">
                                                <div class="span1">
                                                    <label for="returnType0">至起始</label>
                                                </div>
                                                <input id="returnType0" type="radio" class="bui-choose" name="returnType" value="0" checked="checked" />
                                            </li>
                                            <li class="bui-btn bui-box bui-btn-line">
                                                <div class="span1">
                                                    <label for="returnType1">至上一步</label>
                                                </div>
                                                <input id="returnType1" type="radio" class="bui-choose" name="returnType" value="1" />
                                            </li>
                                        </ul>
                                    </div>
                                }

                                <div class="span12">
                                    <div class="bui-input">
                                        <textarea placeholder="意见" id="opinion" rows="4"></textarea>
                                    </div>
                                </div>
                                <div class="span12">
                                    <div id="buiPhoto" class="bui-upload bui-fluid-space-4">
                                        <div class="span1">
                                            <div id="btnUpload" class="bui-btn">
                                                <i class="icon-plus large"></i>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="span12">
                                    <div class="bui-box-space">
                                        <div class="span1">
                                            <div class="bui-btn round primary" id="btnApprove">@(formType == "task"?"审批":"确认")</div>
                                        </div>
                                    </div>
                                </div>
                                @if (formType == "task")
                                {
                                    <div class="span12" style="margin-top:5px;">
                                        <div class="bui-box-space">
                                            <div class="span1" id="btnHelpme">
                                                <div class="bui-btn round">转发查看</div>
                                            </div>
                                            <div class="span1" id="btnAddUser">
                                                <div class="bui-btn round">会签办理</div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="span12" style="margin-top:5px;">
                                        <div class="bui-btn-text" id="help">
                                            <i class="fa fa-question-circle"></i>
                                            说明
                                        </div>
                                    </div>
                                }
                            </div>
                        }

                        <div class="section-title">流程日志</div>
                        <ul class="bui-list">
                            @foreach (var item in ViewBag.Historys as List<wf_taskhistoryEntity>)
                            {
                                <li class="bui-btn">
                                    <h3 class="item-title">@item.create_username @item.opinion @(WFTaskBLL.ApproveResultName(item.result)) </h3>
                                    <p class="item-text">@item.nodename @(item.createtime.HasValue?item.createtime.Value.ToString("yyyy-MM-dd HH:mm:ss"):"")</p>
                                </li>
                            }
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </main>
    <footer>
        <ul id="tabFootNav" class="bui-nav">
            <li class="bui-btn bui-box-vertical active">
                <i class="fa fa-keyboard-o"></i>
                <div class="span1">表单</div>
            </li>
            <li class="bui-btn bui-box-vertical">
                <i class="fa fa-code-fork"></i>
                <div class="span1">流程</div>
            </li>
        </ul>
    </footer>
</div>

@section Footer{
    @Html.AppendJs("~/js/mobile/luckyu-mobile-userselect.js")
    @Html.AppendJs("~/Areas/MobileModule/Views/MWorkflow/Form.js")
}